package com.palfund.nested;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Created by clvc on 2017/10/31.
 * 真正的速度是看不见的 !
 * Today is today , we will go !
 */

public class RVAdapter extends RecyclerViewAdapter<String> {
    public int orientation = 0;

    public RVAdapter(Context context) {
        super(context);
    }

    @Override
    public RecyclerViewAdapter.RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int
            viewType) {
        Log.i("RVAdapter", orientation + "---onCreateViewHolder()--->InnerCreate");
        switch (orientation) {
            case 0:
                return new RVViewHolder(mInflater.inflate(R.layout.item_vertical, parent, false));
            case 1:
                return new RVViewHolder(mInflater.inflate(R.layout.item_horizontal, parent, false));
        }
        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerViewAdapter.RecyclerViewHolder holder, int position) {
        Log.i("RVAdapter", orientation + "---onBindViewHolder()--->InnerBind   " + position);
        RVViewHolder rvViewHolder = (RVViewHolder) holder;
        rvViewHolder.mTextView.setText(mList.get(position));
    }

    class RVViewHolder extends RecyclerViewHolder {
        private TextView mTextView;

        public RVViewHolder(View view) {
            super(view);
            mTextView = view.findViewById(R.id.textView_item);
        }
    }
}
